package com.five.taotao.setup;

import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.five.taotao.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class InstallActivity extends AppCompatActivity {

    private  int flag=1;
    @BindView(R.id.item1)
    TextView item1;
    @BindView(R.id.item3)
    TextView item3;
    @BindView(R.id.item4)
    TextView item4;
    @BindView(R.id.show)
    LinearLayout show;
    @BindView(R.id.yes)
    ImageView yes;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_install);
        ButterKnife.bind(this);
    }

    //返回上一界面
    @OnClick(R.id.back)
    public void back(View view){
        finish();
    }

    //开关的实现，是通过更改TextView 的DrawableRight属性来操作的
    @OnClick(R.id.item1)
    public void kaiguan(View view){
        if(flag==1){
            Drawable no=getResources().getDrawable(R.drawable.yes);
            no.setBounds(0,0,no.getMinimumWidth(),no.getMinimumHeight());
            item1.setCompoundDrawables(null, null, no, null);
            flag=0;
        }else{
            Drawable no=getResources().getDrawable(R.drawable.no);
            no.setBounds(0,0,no.getMinimumWidth(),no.getMinimumHeight());
            item1.setCompoundDrawables(null, null, no, null);
            flag=1;
        }

    }

    //消息提醒栏开关的转变以及相关栏目的显示与隐藏
    public  void isShow(View v){
        if(flag==1){
            show.setVisibility(View.VISIBLE);
            yes.setImageResource(R.drawable.yes);
            flag=0;
        }else{
            show.setVisibility(View.GONE);
            yes.setImageResource(R.drawable.no);
            flag=1;
        }
    }

    //检查更新提示
    @OnClick(R.id.item5)
    public void checked(View view){
        Toast.makeText(this, "以是最新版本", Toast.LENGTH_SHORT).show();
//        Toast toast=new Toast(this);
//        //  toast.setText("以是最新版本");
//        toast.setGravity(Gravity.CENTER | Gravity.BOTTOM, 0, 100); //设置偏移量
//        toast.show();
    }

    //清楚缓存提示
    @OnClick(R.id.item6)
    public void clean(View view){
        Toast.makeText(this,"缓存已清除",Toast.LENGTH_SHORT).show();
    }
    //网络使用协议跳转
    @OnClick(R.id.item8)
    public  void http(View view){
        Intent intent=new Intent(this,HttpActivity.class);
        startActivity(intent);
    }

    //关于我们页面跳转
    @OnClick(R.id.item7)
    public  void aboutus(View view){
        Intent intent=new Intent(this,AboutusActivity.class);
        startActivity(intent);
    }
    @OnClick(R.id.item3)
    public void kaiguan1(View view){
        if(flag==1){
            Drawable no=getResources().getDrawable(R.drawable.yes);
            no.setBounds(0, 0, no.getMinimumWidth(), no.getMinimumHeight());
            item3.setCompoundDrawables(null, null, no, null);
            flag=0;
        }else{
            Drawable no=getResources().getDrawable(R.drawable.no);
            no.setBounds(0, 0, no.getMinimumWidth(), no.getMinimumHeight());
            item3.setCompoundDrawables(null, null, no, null);
            flag=1;
        }
    }

    @OnClick(R.id.item4)
    public void kaiguan2(View view){
        if(flag==1){
            Drawable no=getResources().getDrawable(R.drawable.yes);
            no.setBounds(0,0,no.getMinimumWidth(),no.getMinimumHeight());
            item4.setCompoundDrawables(null, null, no, null);
            flag=0;
        }else{
            Drawable no=getResources().getDrawable(R.drawable.no);
            no.setBounds(0,0,no.getMinimumWidth(),no.getMinimumHeight());
            item4.setCompoundDrawables(null, null, no, null);
            flag=1;
        }
    }

}

